﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DataManager;

namespace FILMEK.GUI
{
    public partial class frmBelepes : Form
    {
        Employees m_Employees;

        public frmBelepes()
        {
            InitializeComponent();
            m_Employees = new Employees();
        }

        /// <summary>
        /// A Belepes gombra kattintva ellenorzi, hogy jok-e a megadott adatok
        /// majd atlepik a megfelelo formra
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnEnter_Click(object sender, EventArgs e)
        {
            if (cbAdmin.Checked)
            {
                if (m_Employees.getEmployeeId(tbUserName.Text, tbPassword.Text, 1) != 0)
                {
                    frmFo myForm = new frmFo();
                    Hide();
                    myForm.ShowDialog();
                    Close();
                }
                else
                {
                    MessageBox.Show("Hibas felhasznalonev vagy jelszo!");
                }
            }
            else
            {
                int temp = m_Employees.getEmployeeId(tbUserName.Text, tbPassword.Text, 0); 
                if (temp != 0)
                {
                    frmKolcsonzesek myForm = new frmKolcsonzesek();
                    myForm.setEmployee(temp);
                    Hide();
                    myForm.ShowDialog();
                    Close();
                }
                else
                {
                    MessageBox.Show("Hibas felhasznalonev vagy jelszo!");
                }
            }
        }

    }
}
